using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using PccCommonForC;

public partial class Manager_ProductStore_test : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            GetStore();
            BindData();
        }
    }

    private void SetDataProduct()
    {

    }

    private void GetStore()
    {
        clsWebShop cls = new clsWebShop();
        PccMsg msg = new PccMsg();
        msg.CreateFirstNode("StID", "");
        DataTable dt = cls.Get_StoreByCondition(msg.GetXmlStr).Tables[0];
        ViewState["dtStore"] = dt;
    }

    private void BindData()
    {
        clsWebShop cls = new clsWebShop();
        PccMsg msg = new PccMsg();
        msg.CreateFirstNode("StartDate", Calendar1.Text);
        msg.CreateFirstNode("EndDate", "");
        msg.CreateFirstNode("PdID", "");
        msg.CreateFirstNode("StId", "0");

        DataTable dt = cls.Get_StoreDetailByCondition(msg.GetXmlStr).Tables[0];
        if (dt.Rows.Count <= 0)
        {
            DataRow dr = dt.NewRow();
            dt.Rows.Add(dr);
        }

        grvMaster.DataSource = dt;
        grvMaster.DataBind();
    }
    protected void grvMaster_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            DropDownList ddlStore = (DropDownList)e.Row.FindControl("ddlStore");
            ddlStore.DataSource = (DataTable)ViewState["dtStore"];
            ddlStore.DataTextField = "StName";
            ddlStore.DataValueField = "StID";
            ddlStore.DataBind();
        }
    }
}
